package com.xnyzc.lhy.order.controller.capi.user.tab;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.order.service.user.tab.IOaTabPermissionService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author Bin
 * @Date 2019/7/23 19:22
 **/
@RestController
@RequestMapping("/capi/userTab/oaTabPermission")
public class OaTabPermissionController {

    @Autowired
    private IOaTabPermissionService iOaTabPermissionService;

    /**
     * 根据用户id用户token以及tabId获取tab信息
     * @param tabId 标签id 0个人公务 1
     * @return
     */
    @ApiOperation(value = "根据标签id获取标签信息", notes = "根据标签id获取标签信息")
    @GetMapping(value = "getTabContent")
    public Rv getTabContent(
            @ApiParam(name = "tabId", value = "标签id") @RequestParam(value = "tabId") int tabId
    ){
        long userId = TokenUtil.getTokenUserId();
        if (userId == 0){
            throw PangException.create(EErrorCode.tokenExpire);
        }
        return Rv.wrap(iOaTabPermissionService.getTabContent(userId, tabId));
    }
}
